<template lang="html">
    <div class="finance">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-tickets"></i> 财务管理</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-form :inline="true" class="demo-form-inline" >
                <el-form-item label="手机号" label-width="80px">
                    <el-input v-model="mobile" placeholder="请输入手机号码" style="width:250px"></el-input>
                </el-form-item>
                <el-form-item label="用户昵称" label-width="80px">
                    <el-input v-model="nikeName" placeholder="请输入用户昵称" style="width:250px"></el-input>
                </el-form-item>
              
                    <el-form-item label="开始日期" label-width="80px">
                        <el-date-picker value-format="yyyy-MM-dd" v-model="beginDate" type="date" class="handle-date"
                                        placeholder="选择日期" style="width:250px;"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="结束日期" label-width="80px">
                        <el-date-picker value-format="yyyy-MM-dd" v-model="endDate" type="date" class="handle-date"
                                        placeholder="选择日期" style="width:250px;"></el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="search">查询</el-button>
                        <!-- <el-button type="info" @click="exprot">导出</el-button> -->
                    </el-form-item>
                
                
               <!-- <el-form-item>
                    <el-button type="primary" @click="reset">重置</el-button>
                </el-form-item>-->
            </el-form>
            <div style="height:40px;"></div>
            <el-table :data="tableData" bfinance style="width: 100%" ref="multipleTable">
                <el-table-column prop="order_code" label="订单号" width="240"></el-table-column>
                <el-table-column prop="goods_name" label="商品名称" ></el-table-column>
                <el-table-column prop="mobile" label="手机号码" ></el-table-column>
                <el-table-column prop="spec" label="商品规格" width="180" align="center"></el-table-column>
                <el-table-column prop="total_money" label="商品总价" width="150" align="center"></el-table-column>
                <el-table-column prop="single_price" label="单价" width="150" align="center"></el-table-column>
                <el-table-column prop="pay_money" label="流水金额" width="150" align="center"></el-table-column>
                <el-table-column prop="trans_pay_type" label="支付方式" width="150" align="center"></el-table-column>
                <el-table-column prop="pay_time" label="付款时间" width="180" align="center"></el-table-column>
            </el-table>
            <!-- 分页 -->
            <div class="pagination" v-show="totalPages>1">
                    <el-pagination @current-change="handleCurrentChange" layout="prev, pager, next" :page-size="pageSize" :total="totalElements" background>
                    </el-pagination>
            </div>
        </div>
    </div>

  </div>
</div>
</template>

<script>
import {getFinacneList,} from '@/api/finance'
    export default {
        name: "finance",
        data() {
            return {
                pageIndex: 1,//当前页码
                pageSize: 10,//每页12条
                totalPages: 1,//默认的总页数
                totalElements:1,//总条数
                tableData: [],//表格数据
                delVisible: false, //删除确认提示，默认隐藏
                order_code: '',
                source: '1',
                mobile:'',//手机号
                nikeName:'',//昵称
                beginDate: '',
                endDate: '',//开始日期
                value: ''
            }
        },
        mounted() {
            this.getFinanceData();
        },
        methods: {
            //获取data数据
            getFinanceData() {
                getFinacneList(this.nickName,this.mobile,this.beginDate,this.endDate, this.pageIndex,this.pageSize).then((response)=> {
                    console.log(response);
                    if(response.code==200){
                        var data = response.data;//当前返回的数据
                        this.tableData = data.list;//列表数据
                        this.totalElements = data.total; //总条数
                        this.totalPages = Math.ceil(data.total/this.pageSize);//总页数
                    }else{
                        this.$notify.error({
                            title: '异常',
                            offset: 100,
                            message: response.msg
                        });
                    }
                 })
            },
            // 分页导航
            handleCurrentChange(val) {
                this.pageIndex = val
                this.getFinanceData()
                // this.cur_page = val;
                //     this.getData();
            },
            //查询
            search() {
                this.getFinanceData();
            },
            //导出
            exprot(){
                if(this.beginDate!="" &&this.endDate==""||this.beginDate=="" &&this.endDate!=""){
                    this.$notify({
                        title: '警告',
                        message: '请选择开始日期与结束日期',
                        type: 'warning'
                    });
                }else{
                    var str ="";
                    // if(this.order_code!=""){
                    //     str +='&id='+this.order_code;
                    // }
                    if(this.nikeName!=""){
                        str +='&nikeName='+this.nikeName;
                    }
                    if(this.beginDate!=""){
                        str +='&beginDate='+this.beginDate;
                    }
                    if(this.endDate!=""){
                        str +='&endDate='+this.endDate;
                    }
                    if(str!=""){
                        str ="?"+str.slice(1);
                    }   
                    
                    //console.log(str);
                    window.open("http://api.xfkka.com/manage/finance/export"+str);  
                }
                
                
            }
        }
    }
</script>

<style lang="css">
</style>
